#include <gtest/gtest.h>
#include <iostream>

class HashTestEnv: public testing::Test { 
public: 
    static void SetUpTestCase() { 
        std::cout << "第一个 TEST 之前被调用,进行总体环境配置\n"; 
    } 
    static void TearDownTestCase() { 
        std::cout << "最后一个 TEST 之后被调用,进行总体环境清理\n"; 
    } 
    virtual void SetUp() override{ 
        std::cout << "测试前: 提前准备数据!!\n"; 
        dict.insert(std::make_pair("bye", "再见")); 
        dict.insert(std::make_pair("see you", "再见")); 
    } 
    virtual void TearDown() override{ 
        std::cout << "测试结束: 清理数据!!\n"; 
        dict.clear();
    }
    std::unordered_map<std::string, std::string> dict;
}; 

TEST_F(HashTestEnv, insert_test) { 
    std::cout << "中间测试\n"; 
    dict.insert(std::make_pair("hello", "你好")); 
    ASSERT_EQ(dict.size(), 3); 
} 
TEST_F(HashTestEnv, size_test) { 
    std::cout << "中间 size 测试\n"; 
    auto it = dict.find("hello"); 
    ASSERT_EQ(it, dict.end()); 
    ASSERT_EQ(dict.size(), 2); 
} 
 
int main(int argc, char *argv[]) { 
    testing::InitGoogleTest(&argc, argv); 
    return RUN_ALL_TESTS();
} 